<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Copyright (C) 2007  Harlan Iverson <h.iverson at gmail.com>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>MUC</title>
        
        <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
        <script type="text/javascript">
            _uacct = "UA-1539394-2";
            urchinTracker();
        </script>
        
        <script type="text/javascript" src="scripts/prototype/prototype.js"> </script> 
        
        <script type="text/javascript" src="scripts/extjs-debug/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="scripts/extjs-debug/ext-all-debug.js"></script>     
        
        <script type="text/javascript" src="scripts/crypto/md5.js">
            <!-- for SASL auth -->
        </script>   
        <script type="text/javascript" src="scripts/crypto/sha1.js">
            <!-- for KeySequence -->
        </script>       
        
        <script type="text/javascript" src="scripts/xmpp4js/xmpp4js.js"> </script>

        <script type="text/javascript">
        
function send_too_many_packets() {
    var con = soashableClient._jabberConnection;
    var packetHelper = con.getPacketHelper();
    
    con.send( packetHelper.createPresence() );
    con.send( packetHelper.createPresence() );
    con.send( packetHelper.createPresence() );
    con.send( packetHelper.createPresence() );
    con.send( packetHelper.createPresence() );
    con.send( packetHelper.createPresence() );
    
    
}

function sendPacketXml() {
    var xml = document.getElementById('packetXml').value;
    
    var con = soashable.getConnection();
    con.sendXml( xml );
}
function receivePacketXml() {
    var xml = document.getElementById('packetXml').value;
    var packetNode = parseXmlToDoc( xml ).documentElement;
    
    
    var reader = soashable.getConnection().getStream().getReader();
    reader.handleResponse( packetNode );
}

function getMucList() {

    var extProvider = new Xmpp4Js.Ext.PacketExtensionProvider()
    extProvider.register( Xmpp4Js.Ext.Muc.XMLNS, Xmpp4Js.Ext.Muc );
    extProvider.register( Xmpp4Js.Ext.MucUser.XMLNS, Xmpp4Js.Ext.MucUser );
    extProvider.register( Xmpp4Js.Ext.Error.XMLNS, Xmpp4Js.Ext.Error );
    
    var con = new Xmpp4Js.JabberConnection( "soashable.com", "/http-bind/" );
    
    con.on( "beginsession", function() {
        con.authenticatePlaintext( "harlan2", "test", "Soashable" ); 
    }, this );
    
    con.on( "onauth", function() {
        con.send(con.getPacketHelper().createPresence());
        
        var mucMan = Xmpp4Js.Muc.MucManager.getInstanceFor( con, "conference.soashable.com", extProvider );
        /*
        mucMan.getRoomList(function(mucMan, rooms) {
            console.dir( rooms );
            
            con.close();
        });
        */
        var room = mucMan.getRoom( "soashable" ).createState();
        
        room.on({
            scope: this,
            join: function(room, participant, packet) {
                    room.sendText( "suppp" );
                    var participants = room.getParticipants(function(room, participants) {
                        //console.dir( participants );
                        room.part();
                    });
                },
            error: function(room, participant, packet) {
                    console.error( "There was an error joining the chat." );
                    console.dirxml( packet.getExtension( ErrorExtension.XMLNS ).getNode() );
                }
        });
        
        room.join( "harlan2" );
        
        
    }, this );
    
    con.beginSession();
}
        
        </script>
        
        <link href="style/soashable.css" rel="stylesheet" type="text/css"/> 
        
        <link rel="stylesheet" type="text/css" href="scripts/extjs-debug/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="scripts/extjs-debug/css/xtheme-aero.css" /><!-- LIBS -->
        
        <!-- Conditionally load CSS based on our defined view -->
        <link rel="stylesheet" type="text/css" href="themes/xtheme-aero/default.css" />
    </head>
    <body>
        testa
        <div id="logo_pane">
            <h1><img src="images/soashable-logo.png" title="Soashable"/></h1>
            <p>"The <em title="The system that says you are not allowed to share or change software is antisocial. -RMS">social</em> web-based messenger"</p>
            <p><span style="color: red">Danger: Extreme Alpha</span>. To suggest features or report bugs, please use the <a href="http://code.google.com/p/soashable/issues/list?can=1" target="soashable_bugs">bug tracker</a>.</p>
        </div>
        
        <textarea id="packetXml" rows="15" cols="100"></textarea>
        <button onclick="sendPacketXml();");">Send Packet</button>
        <button onclick="receivePacketXml();");">Simulate Incoming Packet</button>
        <button onclick="getMucList();">Get MUC List</button>
    </body>
</html>
